home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d939.lha / Upcat / DemoMacro.upcat next >
Text File  |  1993-12-20  |  8KB  |  332 lines

  1. /*-----------------------------------------------------------------------*/
  2. /* ARexx macro DemoMacro for Upcat.                                      */
  3. /*                                                                       */
  4. /* This macro shows some of the macro possibilities of Upcat.            */
  5. /*                                                                       */
  6. /* You may adapt this macro or use parts of it for your own needs, but   */
  7. /* this macro must be distributed unchanged.                             */
  8. /*                                                                       */
  9. /* Author : Frans Zuydwijk                                               */
  10. /* Date   : 24 September 1993                                            */
  11. /*-----------------------------------------------------------------------*/
  12.  
  13. Trace Off
  14.  
  15. Options Results    /* Get information returned in Result */
  16.  
  17. FileSelection = 'OFF'
  18.  
  19. Do Forever
  20.    Say ' 1. Show categories'
  21.    Say ' 2. Show volumes'
  22.    Say ' 3. Show directories'
  23.    Say ' 4. Show files'
  24.    Say ' 5. Show files sorted'
  25.    Say ' 6. Toggle file selection'
  26.    Say ' 7. Show records with path'
  27.    Say ' 8. Show selected record'
  28.    Say ' 9. Show requester'
  29.    Say '10. Open window on Upcat screen'
  30.    Say ' X. Exit macro'
  31.    Say
  32.  
  33.    Options Prompt 'Choice : '
  34.    Pull Choice
  35.    Options Prompt 
  36.    Say
  37.  
  38.    Select
  39.       When Choice = '1'  Then Call ShowCategories
  40.       When Choice = '2'  Then Call ShowVolumes
  41.       When Choice = '3'  Then Call ShowDirectories
  42.       When Choice = '4'  Then Call ShowFiles
  43.       When Choice = '5'  Then Call ShowFilesSorted
  44.       When Choice = '6'  Then Call ToggleFileSelect
  45.       When Choice = '7'  Then Call ShowRecords
  46.       When Choice = '8'  Then Call ShowSelected
  47.       When Choice = '9'  Then Call ShowRequester
  48.       When Choice = '10' Then Call OpenWindow
  49.       When Choice = 'X'  Then Leave
  50.       Otherwise Nop
  51.    End
  52. End
  53.  
  54. Exit
  55.  
  56. /*-----------------------------------------------------------------------*/
  57. /* Show Categories                                                       */
  58. /*-----------------------------------------------------------------------*/
  59.  
  60. ShowCategories : Procedure
  61.  
  62. Say 'Category         Number  Files'
  63. Say
  64.  
  65. "FirstCat"
  66.  
  67. Do While RC = 0
  68.    Parse Var Result Name '/' Number '/' Count
  69.  
  70.    If Name ~= ''
  71.    Then Say Left(Name,15) '  ' Right(Number,2) '  ' Right(Count,5)
  72.  
  73.    "NextCat"
  74. End
  75.  
  76. Call PressReturn
  77.  
  78. Return
  79.  
  80. /*-----------------------------------------------------------------------*/
  81. /* Show Volumes                                                          */
  82. /*-----------------------------------------------------------------------*/
  83.  
  84. ShowVolumes : Procedure
  85.  
  86. "FirstVol"
  87.  
  88. Do While RC = 0
  89.    Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  90.                     Time '/' Protect '/' Categories '/' Comment
  91.  
  92.    Say Left(Name,30) Right(Size,6) 'KB Free' 
  93.  
  94.    "NextVol"
  95. End
  96.  
  97. Call PressReturn
  98.  
  99. Return
  100.  
  101. /*-----------------------------------------------------------------------*/
  102. /* Show Directories                                                      */
  103. /*-----------------------------------------------------------------------*/
  104.  
  105. ShowDirectories : Procedure
  106.  
  107. "FirstDir"
  108.  
  109. Do While RC = 0
  110.    Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  111.                     Time '/' Protect '/' Categories '/' Comment
  112.  
  113.    Say Left(Name,30) Date Time 
  114.  
  115.    "NextDir"
  116. End
  117.  
  118. Call PressReturn
  119.  
  120. Return
  121.  
  122. /*-----------------------------------------------------------------------*/
  123. /* Show Files                                                            */
  124. /*-----------------------------------------------------------------------*/
  125.  
  126. ShowFiles : Procedure
  127.  
  128. Say 'The following list may be aborted by pressing RETURN'
  129. Say
  130.  
  131. "FirstFile"
  132.  
  133. Do While (RC = 0) & (Lines(StdIn) = 0)
  134.  
  135.    Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  136.                     Time '/' Protect '/' Categories '/' Comment
  137.  
  138.    Say Left(Name,30) Date Time Right(Size,8) Protect  
  139.  
  140.    "NextFile"
  141. End
  142.  
  143. Call PressReturn
  144.  
  145. Return
  146.  
  147. /*-----------------------------------------------------------------------*/
  148. /* Show Files Sorted                                                     */
  149. /*-----------------------------------------------------------------------*/
  150.  
  151. ShowFilesSorted : Procedure
  152.  
  153. Say 'The following list may be aborted by pressing RETURN'
  154. Say
  155.  
  156. "FirstSortFile"
  157.  
  158. Do While (RC = 0) & (Lines(StdIn) = 0)
  159.          
  160.    Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  161.                     Time '/' Protect '/' Categories '/' Comment
  162.  
  163.    Say Left(Name,30) Date Time Right(Size,8) Protect  
  164.  
  165.    "NextSortFile"
  166. End
  167.  
  168. If RC = 11
  169. Then Say "Display type is not 'Files - xxx sorted'"  
  170.  
  171. Call PressReturn
  172.  
  173. Return
  174.  
  175. /*-----------------------------------------------------------------------*/
  176. /* Toggle FileSelect                                                     */
  177. /*-----------------------------------------------------------------------*/
  178.  
  179. ToggleFileSelect : Procedure Expose FileSelection
  180.  
  181. If FileSelection = 'OFF' Then Argument = 'ON'; Else Argument = 'OFF'
  182.  
  183. "FileSelect" Argument
  184.  
  185. If RC = 0
  186. Then Do
  187.      FileSelection = Argument
  188.      Say 'FileSelect is now' FileSelection
  189.      End
  190.  
  191. If RC = 11
  192. Then Say 'No file selection criteria set; FileSelect is OFF'
  193.  
  194. Say
  195.  
  196. Return
  197.  
  198. /*-----------------------------------------------------------------------*/
  199. /* Show Records                                                          */
  200. /*-----------------------------------------------------------------------*/
  201.  
  202. ShowRecords : Procedure
  203.  
  204. Say 'The following list may be aborted by pressing RETURN'
  205. Say
  206.  
  207. "FirstRec"
  208.  
  209. Do While (RC = 0) & (Lines(StdIn) = 0)
  210.  
  211.    Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  212.                     Time '/' Protect '/' Categories '/' Comment
  213.  
  214.    "Path"
  215.    Name = Result || Name
  216.  
  217.    Type = Word('Volume Directory File', Pos(Type, 'VDF'))
  218.  
  219.    Say Left(Type,9) Name 
  220.  
  221.    "NextRec"
  222. End
  223.  
  224. Call PressReturn
  225.  
  226. Return
  227.  
  228. /*-----------------------------------------------------------------------*/
  229. /* Show selected record                                                  */
  230. /*-----------------------------------------------------------------------*/
  231.  
  232. ShowSelected : Procedure
  233.  
  234. "SelectRec"
  235.  
  236. If RC = 10
  237. Then Do
  238.      Say 'You must select a record first'
  239.      Say 
  240.      Return
  241.      End
  242.  
  243. Parse Var Result Level '/' Type '/' Name '/' Size '/' Date '/' , 
  244.                  Time '/' Protect '/' Categories '/' Comment
  245.  
  246. "Path"
  247. Path = Result
  248.  
  249. Say 'Level      :' Level
  250. Say 'Type       :' Type
  251. Say 'Name       :' Name
  252. Say 'Path       :' Path
  253. Say 'Size       :' Size
  254. Say 'Date       :' Date
  255. Say 'Time       :' Time
  256. Say 'Protect    :' Protect
  257. Say 'Categories :' Categories
  258. Say 'Comment    :' Comment
  259.  
  260. Call PressReturn
  261.  
  262. Return
  263.  
  264. /*-----------------------------------------------------------------------*/
  265. /* Show requester                                                        */
  266. /*-----------------------------------------------------------------------*/
  267.  
  268. ShowRequester : Procedure
  269.  
  270. Say 'The requester is on the Upcat main window now'
  271. Say
  272.  
  273. "Requester" "Continue" "Demonstration requester|1-3 lines can be displayed"
  274.  
  275. "Requester" "OK|Cancel" "You can use the requester|to make choices"
  276.  
  277. If RC = 0 Then Choice = 'OK'
  278. If RC = 5 Then Choice = 'Cancel'
  279.  
  280. "Requester" "Continue" "You chose" Choice || "|Go back to macro window"
  281.  
  282. Return
  283.  
  284. /*-----------------------------------------------------------------------*/
  285. /* Open window on Upcat screen                                           */
  286. /*-----------------------------------------------------------------------*/
  287.  
  288. OpenWindow : Procedure
  289.  
  290. "ScreenName"
  291.  
  292. WindowParms = 'CON:160/50/320/100/Test window/Screen' Result
  293.  
  294. If Open('Console', WindowParms) = 0
  295. Then Do
  296.      Say 'Cannot open window'
  297.      Say
  298.      Return
  299.      End
  300.  
  301. "CatalogName"
  302.  
  303. WriteLn('Console', 'CatalogName is :' Result)
  304. WriteLn('Console', '')
  305.  
  306. Do Forever
  307.    WriteLn('Console', 'Type EXIT to close window')
  308.  
  309.    If Upper(ReadLn('Console')) = 'EXIT' Then Leave
  310.    End
  311.  
  312. Close('Console')
  313.  
  314. Return
  315.  
  316. /*-----------------------------------------------------------------------*/
  317. /* Wait until RETURN is pressed                                          */
  318. /*-----------------------------------------------------------------------*/
  319.  
  320. PressReturn : Procedure
  321.  
  322. Do While Lines(StdIn) ~= 0
  323.    Pull
  324. End
  325.  
  326. Say
  327. Say 'Press RETURN to continue...'
  328.  
  329. Pull
  330.  
  331. Return
  332.